const http = require("http");

// http.get(
//   {
//     host: "localhost",
//     port: 1234,
//     path: "/?a=1",
//   },
//   (res) => {
//     console.log(res);
//   }
// );

let options = {
  host: "localhost",
  port: 1234,
  path: "/?a=1",
  method: "POST",
  headers: {
    // "Content-type": "application/json",
    "Content-type": "application/x-www-form-urlencoded",
  },
};

let req = http.request(options, (res) => {
  let arr = [];
  res.on("data", (data) => {
    arr.push(data);
  });
  res.on("end", () => {
    console.log(Buffer.concat(arr).toString());
  });
});

// req.end("今天是个好日子");
// req.end('{"name": "花花"}');
req.end("a=4&b=2");
